var openid = getQueryString("openid");

function personInfo(){

	$.ajax({
		url: API_URL+'agent/getbyopenid?openid='+ openid,
		type: 'GET',
		dataType: "JSON",
		data:'',
		async: false,
		success: function (obj){
			var myData = obj.data[0];
			if(myData.icon == null || myData.icon == ''){
				myData.icon = '../img/default.png';
			}
			person_head = $('.person_head').css({
				'background': 'url('+myData.icon+') no-repeat',
				'background-size': '100% 100%'
				});

			$('#id').text(myData.id);
			$('#name').text(myData.name);
			$('#gender').text(myData.gender);
			var ageStr = myData.age;
			if(ageStr==0){
				ageStr='未设置';
			}
			$('#age').text(ageStr);
			$('#birthday').text(myData.birthday);
			$('#native_place').text(myData.native_place);
			$('#political_status').text(myData.political_status);
			$('#education').text(myData.education);
			$('#school').text(myData.school);
			$('#professional').text(myData.professional);	
			$('#entry_time').text(myData.entry_time);	
			$('#regional').text(myData.regional);	
			$('#channel').text(myData.channel);	
			$('#branch').text(myData.branch);	
			$('#located_branch').text(myData.located_branch);	
			$('#department').text(myData.department);	
			$('#email').text(myData.email);	
			$('#position').text(myData.position);	
			$('#position_time').text(myData.position_time);	
			$('#training_type').text(myData.training_type);	
			$('#number_of_periods').text(myData.number_of_periods);	
			$('#experience').text(myData.experience);	

			var detialObj = $('ul li');
			for( var i = 0; i < detialObj.length; i++ ){
				var detialsTextObj = $(detialObj[i]).children('span');
				var detialsText =detialsTextObj.text();
				if(detialsText == 'null' || detialsText == ''){
						$(detialsTextObj).text('未设置')
					}	
			}			
		},
		error: function (data){
			console.log("服务器异常!");
		}
	});
}
$(function(){
		$('#rewrite_info').on('click',function(){
		window.location = 'rewrite_person_info.html?openid='+openid;
	})
		$('#rewrite_company').on('click',function(){
		window.location = 'rewrite_company_info.html?openid='+openid;
	})
});
